/* eslint-disable @typescript-eslint/no-empty-object-type */
import { requestClient } from '#/api/request';

export namespace unitmeasureAPI {
  export interface unitmeasures {
    code: number;
    msg: string;
    rows: [];
    total: number;
  }

  export interface Params {}
  export interface Datum {
    searchValue: null;
    createBy: string;
    createTime: string;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    measureId: number;
    measureCode: string;
    measureName: string;
    primaryFlag: string;
    primaryId: null | number;
    changeRate: number;
    enableFlag: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }

  export interface unitmeasureAll {
    msg: string;
    code: number;
    data: Datum[];
  }
}

export const getUnitmeasures = (params?: {
  itemTypeId?: number;
  page?: number;
  pageSize?: number;
}) => {
  return requestClient.get<unitmeasureAPI.unitmeasures>(
    '/mes/md/unitmeasure/list?pageNum=1&pageSize=10',
    {
      params,
    },
  );
};

// 获取单位列表
export const getUnitmeasureAll = () => {
  return requestClient.get<unitmeasureAPI.unitmeasureAll>(
    'mes/md/unitmeasure/selectall',
  );
};

// 删除单位编号
export const deleteUnit = (id: string) =>
  requestClient.delete<unitmeasureAPI.unitmeasureAll>(
    `/mes/md/unitmeasure/${id}`,
  );
// 新增单位编号
export const addUnit = (data: unitmeasureAPI.Datum) =>
  requestClient.post<unitmeasureAPI.unitmeasureAll>(
    '/mes/md/unitmeasure',
    data,
  );

// 修改单位编号
export const updateUnit = (data: unitmeasureAPI.Datum) =>
  requestClient.put<unitmeasureAPI.unitmeasureAll>('/mes/md/unitmeasure', data);
